package com.chen.controller;

import com.chen.common.Result;
import com.chen.pojo.Album;
import com.chen.service.AlbumService;
import com.chen.service.Impl.AlbumServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author chenchao
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/album")
@Api(value = "AlbumController",tags = "相册")
public class AlbumController {
    @Resource
    private AlbumServiceImpl albumService;


    @PostMapping("/addAblum")
    @ApiOperation("添加图片")
    public Result<?> addAlbum(@RequestBody Album album){
        return albumService.addAlbum(album);
    }

    @PutMapping("/updateAblum")
    @ApiOperation("编辑图片")
    public Result<?> updateAblum(@RequestBody  Album album){
        return albumService.updateAlbum(album);
    }

    @DeleteMapping("/deleteAblum/{scope}/{id}")
    @ApiOperation("删除图片")
    public Result<?> deleteAblum(@PathVariable("scope") String scope, @PathVariable("id") int id){
        return albumService.deleteAlbum(id,scope);
    }

    @GetMapping("/findAlbumAll")
    @ApiOperation("查询所有图片")
    public Result<?> findAlbumAll(){
        return albumService.findAll();
    }

    @GetMapping("/findAlbumOne/{name}")
    @ApiOperation("查询某个人所有的图片")
    public Result<?> findAlbumOne(@PathVariable("name") String name){
        return albumService.albumList(name);
    }

    @GetMapping("/query/{id}")
    @ApiOperation("查询")
    public Result<?> getById(@PathVariable("id") Long id) {
        return albumService.getById(id);
    }

    @GetMapping("/query/categoryImg")
    @ApiOperation("统计")
    public Result<?> categoryImg(){
        return albumService.categoryImg();
    }

    @GetMapping("/query/categoryList/{name}/{category}")
    @ApiOperation("统计类别")
    public Result<?> categoryList(@PathVariable("name") String name,@PathVariable("category") String category){
        return albumService.categoryList(name,category);
    }


    @GetMapping("/categoryLists/{name}")
    @ApiOperation("统计类别")
    public Result<?> categoryLists(@PathVariable("name") String name){
        return albumService.categoryImgs(name);
    }

}
